xend: insufficient quoting in tapdisk
authorPhilipp Hahn <hahn@univention.de>
Thu, 1 Dec 2011 18:30:29 +0000 (18:30 +0000)
committerPhilipp Hahn <hahn@univention.de>
Thu, 1 Dec 2011 18:30:29 +0000 (18:30 +0000)
insufficient quoting between "tap-ctl list" and xend/server/BlktapController.py

BlktapController splits the output into lines using \n, then each line
at each space, and finally each of these 'words' at the '=', which
fails if the filename contains spaces.

As a quick work-around, the attached patch fixes the problem for me. That is,
until tap-ctl changes it's output format.

A more permanent solution would be to add proper quoting / escaping to tap-ctl
and un-quoting / de-escaping  to BlktapController.py

Signed-off-by: Philipp Hahn <hahn@univention.de>
Committed-by: Ian Jackson <ian.jackson@eu.citrix.com>
tools/python/xen/xend/server/BlktapController.py

index 7d4e5a88d59b72d0d8d389d6905bc64b8c4c1542..51647e2d92007efc313c9152cd8ccd3e0db0fe04 100644 (file)
@@ -249,11 +249,12 @@ class TapdiskController(object):
         _list = TapdiskController.exc('list')
         if not _list: return []
 
-        for line in _list.split('\n'):
+        for line in _list.splitlines():
             tapdisk = TapdiskController.Tapdisk()
 
-            for pair in line.split():
-                key, value = pair.split('=')
+            # Since 'tap-ctl list' does not escape blanks in the path, hard-code the current format using 4 pairs to prevent splitting the path
+            for pair in line.split(None, 4):
+                key, value = pair.split('=', 1)
                 if key == 'pid':
                     tapdisk.pid = value
                 elif key == 'minor':
@@ -264,7 +265,7 @@ class TapdiskController(object):
                 elif key == 'state':
                     tapdisk.state = value
                 elif key == 'args' and value.find(':') != -1:
-                    tapdisk.dtype, tapdisk.image = value.split(':')
+                    tapdisk.dtype, tapdisk.image = value.split(':', 1)
 
             tapdisks.append(tapdisk)